package net.j4love.spring.boot.shutdownhook;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;

/**
 * @author He Peng
 * @create 2017-05-19 11:59
 * @update 2017-05-19 11:59
 * @see
 */

@ComponentScan(basePackages = "net.j4love.spring.boot.shutdownhook")
@EnableAutoConfiguration
public class SpringBootApplication {

    public static void main(String[] args) throws InterruptedException {

        ConfigurableApplicationContext applicationContext =
                SpringApplication.run(SpringBootApplication.class, args);

        Thread.sleep(2000);
        // System.exit(0); // 可以触发 jvm 的 shutdown hook
        // System.exit(-1); // 可以触发 jvm 的 shutdown hook

        applicationContext.close(); // 可以触发 jvm 的 shutdown hook
    }
}
